package se.webbzon.oschi01.resourceset;

import java.util.Collection;

public class ResourceSet<R> {
	
	// An array of all resources in this set
	private final R[] resources;
		
	/*============================================================
	Constructors
	============================================================*/
		
	/** Creates a new generic ResourceSet from a collection of resources. **/
	@SuppressWarnings("unchecked")
	public ResourceSet(Collection<R> resources) {
		this.resources = (R[]) resources.toArray();
	}
		
	/** Creates a new generic ResourceSet from an array of resources. **/
	public ResourceSet(R[] resources) {
		this.resources = resources.clone();
	}
		
	/*============================================================
	Public Methods
	============================================================*/
		
	/** Returns the (n+1):th resource from the resource set. **/
	public R get(int n) {
		return resources[n];
	}
		
	/** Returns the number of resources in this resource set. **/
	public int size() {
		return resources.length;
	}

}
